<!--title-->
<div class="mnav1">
	<div class="m_nav">
		<div class="nav_left">
			<em class="home_icon"><?=$this->sys_name?></em><span>&nbsp;&gt;&nbsp;</span><font><?=$this->title?></font>
		</div>
	</div>
</div>

<div class="content-table2">
<div class="content-table-title"><?=$this->title?></div>
<br />
<?php if($this->msg):?>
<div class="replace"><?=$this->msg?></div>
<br />
<?php endif;?>
<div class="form-edit-task">

<form action="/maozhua/edit-user-submit" method="post" name="form1" onsubmit="submitform(this);return false;">
<table border="0" width="100%">
	<tr>
		<td align="right" width="30%">公司名称：</td>
		<td align="left">&nbsp;<input type="text" placeholder="公司名称" name="user_name" id="user_name" autocomplete="off" value="<?=$this->data['user_name']?>" onkeyup="SearchDealer(this)" style="width: 300px"></td>
	</tr>
    <tr>
        <td align="right" width="30%">车智汇通Dealer ID：</td>
        <td align="left">&nbsp;<input type="text" name="czht_dealer_id" id="czht_dealer_id" autocomplete="off" value="<?=$this->data['czht_dealer_id']?>" style="width: 300px"><font color="red"> * 填写公司名称自动匹配</font></td>
    </tr>
    <tr>
        <td align="right" width="30%">合同编号：</td>
        <td align="left">&nbsp;<input type="text" name="contract_sid" id="contract_sid" autocomplete="off" value="<?=$this->data['contract_sid']?>" style="width: 300px"><font>填写合同编号(多个用英文 ' , ' 分开)</font></td>
    </tr>
	<tr>
		<td align="right">省份：</td>
		<td align="left"><select name="provinceId" id="provinceId" onchange="GetCities(this.options[this.options.selectedIndex].value);">
					<option value="">不限</option>
					<?php if(!empty($this->provinces)):?>
					<?php foreach($this->provinces as $provinceId => $provinceName):?>
					<option value="<?=$provinceId?>" <?php if($provinceId==$this->data['province_id']){echo "selected='selected'";}?>><?=$provinceName?></option>
					<?php endforeach;?>
					<?php endif;?>
				</select>
		</td>
	</tr>
	<tr>
		<td align="right">城市：</td>
		<td align="left"><select name="cityId" id="cityId" onchange="GetCounties(this.options[this.options.selectedIndex].value);">
			<?php if($this->init_cities):?>
				<?php foreach($this->init_cities as $cities):?>
				<option value="<?=$cities['cityId']?>" <?php if($cities['cityId']==$this->data['city_id']){echo "selected='selected'";}?>><?=$cities['cityName']?></option>
				<?php endforeach;?>
			<?php endif;?>
			</select></td>
	</tr>
	<tr>
		<td align="right">手机/登录ID：</td>
		<td align="left">&nbsp;<input type="text" placeholder="手机" name="cellphone" id="cellphone" value="<?=$this->data['cellphone']?>"></td>
	</tr>
	<tr>
		<td align="right">登录密码：</td>
		<td align="left">&nbsp;<input type="text" placeholder="无需修改请留空" name="pwd" id="pwd"><font color="red"> * 初始密码为123456</font></td>
	</tr>
    <tr>
        <td align="right">起始日：</td>
        <td align="left">&nbsp;<input type="text" name="start_date" id="start_date" style="width: 100px"></td>
    </tr>
	<tr>
		<td align="right">过期日：</td>
		<td align="left">&nbsp;<input type="text" name="expired_date" id="expired_date" style="width: 100px"></td>
	</tr>
	<tr>
		<td align="right">所属销售顾问：</td>
		<td align="left">
			<select name="emp_id" id="emp_id">
				<option value="">请选择</option>
			<?php foreach($this->sales as $emp_id => $name):?>
				<option value="<?=$emp_id?>" <?php if($emp_id==$this->data['emp_id']){echo "selected='selected'";}?>><?=$name?></option>
			<?php endforeach;?>
			</select>
		</td>
	</tr>
	<tr>
		<td align="right">状态：</td>
		<td align="left">
			<select name="status" id="status">
				<option value="0" <?php if(!$this->data['status']){echo "selected='selected'";}?>>待审核</option>
				<option value="1" <?php if($this->data['status']){echo "selected='selected'";}?>>已审核</option>
			</select>
		</td>
	</tr>
	<tr>
		<td colspan="2"><br /><font color="red">需要开通的账号，必须为客户填写经销商ID。用户名和密码可不填，由客户在网站自行填写。<br />ID、用户名和密码齐全时，开关会自动开启。</font><br /></td>
	</tr>
	<?php if(isset($this->accounts[1]['account_id'])):?>
	<tr>
		<td align="right">Account ID：</td>
		<td align="left">&nbsp;<?=$this->accounts[1]['account_id']?></td>
	</tr>
	<?php endif;?>
	<tr>
		<td align="right">汽车之家开关：</td>
		<td align="left">&nbsp;<input type="radio" name="type1_status" id="type1_status_1" value="1" <?php if($this->accounts[1]['status']):?>checked="checked"<?php endif;?>><label for="type1_status_1">&nbsp;启用</label>&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="type1_status" id="type1_status_0" value="0" <?php if(!$this->accounts[1]['status']):?>checked="checked"<?php endif;?>><label for="type1_status_0">&nbsp;关闭</label>
		<?php if(!$this->accounts[1]['status'] && 0 < $this->accounts[1]['err_login_times']):?>&nbsp;&nbsp;&nbsp;&nbsp;<font color="red">(用户名或密码错误)</font><?php endif;?>
		</td>
	</tr>
	<tr>
		<td align="right">汽车之家经销商ID：</td>
		<td align="left">&nbsp;<input type="text" placeholder="汽车之家经销商ID" name="type1_dealer_id" id="type1_dealer_id" value="<?=$this->accounts[1]['dealer_id']?$this->accounts[1]['dealer_id']:""?>"></td>
	</tr>
	<tr>
		<td align="right">汽车之家用户名：</td>
		<td align="left">&nbsp;<input type="text" placeholder="汽车之家用户名" name="type1_user_name" id="type1_user_name" value="<?=$this->accounts[1]['user_name']?$this->accounts[1]['user_name']:""?>"></td>
	</tr>
	<tr>
		<td align="right">汽车之家密码：</td>
		<td align="left">&nbsp;<input type="text" placeholder="无需更改请留空" name="type1_pwd" id="type1_pwd"></td>
	</tr>
	<tr>
		<td colspan="2"><br /></td>
	</tr>
	<?php if(isset($this->accounts[4]['account_id'])):?>
	<tr>
		<td align="right">Account ID：</td>
		<td align="left">&nbsp;<?=$this->accounts[4]['account_id']?></td>
	</tr>
	<?php endif;?>
	<tr>
		<td align="right">汽车之家APP开关：</td>
		<td align="left">&nbsp;<input type="radio" name="type4_status" id="type4_status_1" value="1" <?php if($this->accounts[4]['status']):?>checked="checked"<?php endif;?>><label for="type4_status_1">&nbsp;启用</label>&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="type4_status" id="type4_status_0" value="0" <?php if(!$this->accounts[4]['status']):?>checked="checked"<?php endif;?>><label for="type4_status_0">&nbsp;关闭</label>
		<?php if(!$this->accounts[4]['status'] && 0 < $this->accounts[4]['err_login_times']):?>&nbsp;&nbsp;&nbsp;&nbsp;<font color="red">(用户名或密码错误)</font><?php endif;?>
		</td>
	</tr>
	<tr>
		<td align="right">汽车之家APP经销商ID：</td>
		<td align="left">&nbsp;<input type="text" placeholder="汽车之家APP经销商ID" name="type4_dealer_id" id="type4_dealer_id" value="<?=$this->accounts[4]['dealer_id']?$this->accounts[4]['dealer_id']:""?>"></td>
	</tr>
	<tr>
		<td align="right">汽车之家APP用户名：</td>
		<td align="left">&nbsp;<input type="text" placeholder="汽车之家APP用户名" name="type4_user_name" id="type4_user_name" value="<?=$this->accounts[4]['user_name']?$this->accounts[4]['user_name']:""?>"></td>
	</tr>
	<tr>
		<td align="right">汽车之家APP密码：</td>
		<td align="left">&nbsp;<input type="text" placeholder="无需更改请留空" name="type4_pwd" id="type4_pwd"></td>
	</tr>
	<tr>
		<td colspan="2"><br /></td>
	</tr>
	<?php if(isset($this->accounts[2]['account_id'])):?>
	<tr>
		<td align="right">Account ID：</td>
		<td align="left">&nbsp;<?=$this->accounts[2]['account_id']?></td>
	</tr>
	<?php endif;?>
	<tr>
		<td align="right">易车开关：</td>
		<td align="left">&nbsp;<input type="radio" name="type2_status" id="type2_status_1" value="1" <?php if($this->accounts[2]['status']):?>checked="checked"<?php endif;?>><label for="type2_status_1">&nbsp;启用</label>&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="type2_status" id="type2_status_0" value="0" <?php if(!$this->accounts[2]['status']):?>checked="checked"<?php endif;?>><label for="type2_status_0">&nbsp;关闭</label>
		<?php if(!$this->accounts[2]['status'] && 0 < $this->accounts[2]['err_login_times']):?>&nbsp;&nbsp;&nbsp;&nbsp;<font color="red">(用户名或密码错误)</font><?php endif;?>
		</td>
	</tr>
	<tr>
		<td align="right">易车经销商ID：</td>
		<td align="left">&nbsp;<input type="text" placeholder="易车经销商ID" name="type2_dealer_id" id="type2_dealer_id" value="<?=$this->accounts[2]['dealer_id']?$this->accounts[2]['dealer_id']:""?>"></td>
	</tr>
	<tr>
		<td align="right">易车用户名：</td>
		<td align="left">&nbsp;<input type="text" placeholder="易车用户名" name="type2_user_name" id="type2_user_name" value="<?=$this->accounts[2]['user_name']?$this->accounts[2]['user_name']:""?>"></td>
	</tr>
	<tr>
		<td align="right">易车密码：</td>
		<td align="left">&nbsp;<input type="text" placeholder="无需更改请留空" name="type2_pwd" id="type2_pwd"></td>
	</tr>
	<tr>
		<td colspan="2"><br /></td>
	</tr>
    <br/><br/>
    <?php if(isset($this->accounts[5]['account_id'])):?>
        <tr>
            <td align="right">Account ID：</td>
            <td align="left">&nbsp;<?=$this->accounts[5]['account_id']?></td>
        </tr>
    <?php endif;?>
    <tr>
        <td align="right">易车APP开关：</td>
        <td align="left">&nbsp;<input type="radio" name="type5_status" id="type5_status" value="1" <?php if($this->accounts[5]['status']):?>checked="checked"<?php endif;?>><label for="type5_status_1">&nbsp;启用</label>&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="type5_status" id="type5_status_0" value="0" <?php if(!$this->accounts[5]['status']):?>checked="checked"<?php endif;?>><label for="type5_status_0">&nbsp;关闭</label>
            <?php if(!$this->accounts[5]['status'] && 0 < $this->accounts[5]['err_login_times']):?>&nbsp;&nbsp;&nbsp;&nbsp;<font color="red">(用户名或密码错误)</font><?php endif;?>
        </td>
    </tr>
    <tr>
        <td align="right">易车APP经销商ID：</td>
        <td align="left">&nbsp;<input type="text" placeholder="易车APP经销商ID" name="type5_dealer_id" id="type5_dealer_id" value="<?=$this->accounts[5]['dealer_id']?$this->accounts[5]['dealer_id']:""?>"></td>
    </tr>
    <tr>
        <td align="right">易车APP用户名：</td>
        <td align="left">&nbsp;<input type="text" placeholder="易车APP用户名" name="type5_user_name" id="type5_user_name" value="<?=$this->accounts[5]['user_name']?$this->accounts[5]['user_name']:""?>"></td>
    </tr>
    <tr>
        <td align="right">易车APP密码：</td>
        <td align="left">&nbsp;<input type="text" placeholder="无需更改请留空" name="type5_pwd" id="type5_pwd"></td>
    </tr>
    <tr>
        <td colspan="2"><br /></td>
    </tr>
	<tr>
		<td colspan="2" align="center"><input type="hidden" name="user_id" value="<?=$this->user_id?>" /><input type="button" class="buttonlong" value="提交" onclick="submitform();return false;" /></td>
	</tr>
</table>
<br /><br />
</form>
</div>
<br/><br/>
</div>

<script>
$(function() {
	$( "#expired_date" ).datepicker({ dateFormat: 'yy-mm-dd'}).datepicker("setDate", "<?=$this->data['expired_date']?>");
	$( "#start_date" ).datepicker({ dateFormat: 'yy-mm-dd'}).datepicker("setDate", "<?=$this->data['start_date']?>");
});

function GetCities(provinceId)
{
	$.ajax({
			type: "post",
			url : "/ajax/get-cities",
			dataType:'json',
            async:false,
			data: {
					'provinceId':provinceId
				  },
				success: function(json){
					if(json.result == 1 && typeof(json.data) != "undefined") {
                        var arr = json.data;
						var txt = "<option value=''>不限</option>";
						
                        for(i=0; i < arr.length; i++){
							txt += "<option value='" + arr[i]['cityId'] + "'>" + arr[i]['cityName'] + "</option>";
                        }
						
						document.getElementById("cityId").innerHTML = txt;
                    }
			}
		});
}

function submitform() 
{
    if($('#czht_dealer_id').val().length == 0){
        $('#czht_dealer_id').focus();
        $('#czht_dealer_id').attr('placeholder','请填写车智汇通Dealer ID');
        alert('车智汇通Dealer ID不能为空');
        return false;
    }
	form1.submit();
}

function SearchDealer(element)
{
    var userName = element.value;
    if(userName) {
        $.ajax({
            url: "/ajax/search-dealer-id",
            dataType: 'json',
            type: 'get',
            data: {
                name: userName
            },
            success: function (e)
            {
                $("#czht_dealer_id").val(e.id)
            }
        })
    }

}
</script>
